package org.mspring.mlog.search;

import java.util.List;

import org.mspring.mlog.entity.Post;
import org.mspring.mlog.search.engine.LuceneSearchEngine;
import org.mspring.platform.dao.support.Page;

/**
 * 
 * @author Gao Youbo
 * @since 2013年8月2日
 */
public class Test {
    public static void main(String[] args) throws Exception {
        // LuceneSearchEngine engine = new LuceneSearchEngine();
        // engine.setIndexPath("D:/index");
        // Page page = new Page();
        // page.setPageNo(2);
        // page = engine.doSearch(News.class, "j", new String[] { "title",
        // "content", "summary" }, true, page);
        // System.out.println(page.getResult().size());
        // for (Object object : page.getResult()) {
        // News news = (News) object;
        // System.out.println(news.getTitle());
        // }

        LuceneSearchEngine searchEngine = new LuceneSearchEngine();
        searchEngine.setIndexPath("D:/index");
        Page page = new Page();
        searchEngine.doSearch(Post.class, "java", new String[] { "title", "summary", "content" }, false, page);
        List list = page.getResult();
//        System.out.println(list.size());
        for (Object object : list) {
            Post post = (Post) object;
            System.out.println(post.getTitle());
//            if (post.getTitle().equals("Java")) {
//                System.out.println("$$$$$$$$$$$$$$$$$$$$$$");
//            }
        }
    }
}
